﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="CapNhatTonKho.aspx.cs" Inherits="WebTeamplate.Admin_CapNhatTonKho" %>

<%@ Register Assembly="Control" Namespace="PagerControl" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script src="../Js/BasicFunction.js"></script>

    <script src="../Js/ListView.js"></script>

    <script src="../Js/Popup.js"></script>

    <table class="lvtBg" border="0" cellpadding="0" cellspacing="1" width="100%">
        <tbody>
            <tr>
                <td align="center">
                    <table class="small" border="0" cellpadding="2" cellspacing="5" width="100%">
                        <tr>
                            <td align="right" style="width: 150px;">
                                Chọn Kho:
                            </td>
                            <td align="left" style="width: 150px;">
                                <asp:DropDownList ID="drlKho" Width="120px" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td align="right" style="width: 100px;">
                                Loại mặt hàng:
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="drlLoaiMH" runat="server" Width="120px" AutoPostBack="true"
                                    OnSelectedIndexChanged="drlLoaiMH_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 150px;">
                                Chủng xe
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="drlChungXe" Width="120px" AutoPostBack="true" runat="server"
                                    OnSelectedIndexChanged="drlChungXe_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td align="right">
                                Xe
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="drlXe" Width="120px" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drlXe_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                Mã mặt hàng:
                            </td>
                            <td align="left">
                                <asp:TextBox ID="txtMaMatHang" runat="server" Width="120px"></asp:TextBox>
                            </td>
                            <td align="right">
                                Mã phụ tùng:
                            </td>
                            <td align="left">
                                <asp:TextBox ID="txtMaPhuTung" runat="server" Width="120px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td align="left" colspan="3">
                                <asp:Button ID="btnThongKe" runat="server" Text="Thống kê" OnClick="btnThongKe_Click"
                                    meta:resourcekey="btnSearchResource1" CssClass="crmbutton small edit" />
                                <asp:Button ID="btnReset" runat="server" Text="Reset" meta:resourcekey="btnResetResource1"
                                    CssClass="crmbutton small edit" OnClick="btnReset_Click" />
                                <asp:Button ID="btnSortOrder" runat="server" Text="Sort" OnClick="btnSortOrder_Click"
                                    meta:resourcekey="btnSearchResource1" CssClass="hidButton" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <hr noshade="noshade" size="1">
                </td>
            </tr>
            <tr>
                <td align="right">
                    <cc1:Pager ID="Pager1" runat="server" OnPageIndexChanging="Pager1_PageIndexChanging"
                        OnPageSizeChanging="Pager1_PageSizeChanging" meta:resourcekey="Pager1Resource1"
                        PageIndex="1" PageSize="2" SelectRecord="0" TotalPage="1" TotalRecord="0" />
                </td>
            </tr>
            <tr>
                <td>
                    <%=data %>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <br />
                    <asp:Button ID="btnSave" runat="server" Width="60px" Text="Lưu" OnClientClick="return CheckValidData();"
                        OnClick="btnSave_Click" />
                </td>
            </tr>
        </tbody>
    </table>
    <input type="hidden" value="" id="hidKey" runat="server" />
    <input type="hidden" runat="server" value="" id="hidSortField" />
    <input id="hidSortExpression" type="hidden" runat="server" value="" />

    <script type="text/javascript">
        function SortOrder(field, exp) {
            document.getElementById('<%=hidSortField.ClientID %>').value = field;
            document.getElementById('<%=hidSortExpression.ClientID %>').value = exp;
            var btn = document.getElementById('<%=btnSortOrder.ClientID %>');
            if (btn)
                btn.click();
        }
        function ClearFrom() {
            document.getElementById('<%=drlKho.ClientID %>').value = '';
            document.getElementById('<%=drlChungXe.ClientID %>').value = '';
            document.getElementById('<%=drlXe.ClientID %>').value = '';
            document.getElementById('<%=txtMaMatHang.ClientID %>').value = '';
            document.getElementById('<%=txtMaPhuTung.ClientID %>').value = '';
            return false;
        }

        function CheckValidData() {
            var lstID = document.getElementById('<%=hidKey.ClientID %>').value;
            var arr = new Array();
            arr = lstID.split(';');
            if (arr.length > 0) {
               
                for (var i = 0; i < arr.length; i++) {
                    var id = arr[i].toString();
                    if (id != '') {
                      
                        if (CheckDataByRow(id)) {
                            alert('Vui lòng kiểm tra lại dữ liệu.');
                            return false;
                        }
                    }
                }
            }
            // alert('Vui lòng kiểm tra lại dữ liệu.');
            return true;
        }
        function CheckDataByRow(id) {
            var number = document.getElementById('txtSoLuongTon_' + id).value;
            number = parseInt(number);
            if (!isNaN(number))
                return false;
            return true;

        }   
    </script>

</asp:Content>
